package cn.lxh.user.mapper;

import cn.lxh.basic.mapper.BaseMapper;
import cn.lxh.user.domain.WxPublicOrder;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface WxPublicOrderMappper extends BaseMapper<WxPublicOrder> {

    /**
     *
     * @param oderId
     * @return
     */
    @Select("SELECT * FROM wx_public_order WHERE order_id = #{oderId}")
    WxPublicOrder findByOrderId(@Param("oderId") String oderId);


    /**
     *
     * @param wxPublicOrder
     * @return
     */
    @Insert("INSERT INTO wx_public_order (order_id,template_id,touser_id,status,name,create_time,remark)\n" +
            "VALUES (#{wxPublicOrder.orderId},#{wxPublicOrder.templateId},#{wxPublicOrder.touserId},#{wxPublicOrder.status},#{wxPublicOrder.name},#{wxPublicOrder.createTime},#{wxPublicOrder.remark})")
    int saveWxPublicOrder(@Param("wxPublicOrder") WxPublicOrder wxPublicOrder);

    /**
     *
     * @param wxPublicOrder
     */
    @Update("UPDATE wx_public_order SET template_id=#{wxPublicOrder.templateId},touser_id=#{wxPublicOrder.touserId},status=#{wxPublicOrder.status},name=#{wxPublicOrder.name},create_time=#{wxPublicOrder.createTime},remark=#{wxPublicOrder.remark}\n" +
            "WHERE order_id = #{wxPublicOrder.orderId}")
    void updateOrder(@Param("wxPublicOrder") WxPublicOrder wxPublicOrder);
}
